## Sid Meier's Civilization 4
## Copyright Firaxis Games 2005
##
## Implementaion of miscellaneous game functions

import CvUtil
from CvPythonExtensions import *
import CvEventInterface
import CustomFunctions

# globals
cf = CustomFunctions.CustomFunctions()
gc = CyGlobalContext()

class CvGameUtils:
	"Miscellaneous game functions"
	def __init__(self): 
		pass
	
	def isVictoryTest(self):
		if ( gc.getGame().getElapsedGameTurns() > 10 ):
			return True
		else:
			return False

	def isVictory(self, argsList):
		eVictory = argsList[0]
		return True

	def isPlayerResearch(self, argsList):
		ePlayer = argsList[0]
		return True

	def getExtraCost(self, argsList):
		ePlayer = argsList[0]
		return 0

	def createBarbarianCities(self):
		return False
		
	def createBarbarianUnits(self):
		return False
		
	def skipResearchPopup(self,argsList):
		ePlayer = argsList[0]
		return False
		
	def showTechChooserButton(self,argsList):
		ePlayer = argsList[0]
		return True

	def getFirstRecommendedTech(self,argsList):
		ePlayer = argsList[0]
		return TechTypes.NO_TECH

	def getSecondRecommendedTech(self,argsList):
		ePlayer = argsList[0]
		eFirstTech = argsList[1]
		return TechTypes.NO_TECH
	
	def canRazeCity(self,argsList):
		iRazingPlayer, pCity = argsList
		return True
	
	def canDeclareWar(self,argsList):
		iAttackingTeam, iDefendingTeam = argsList
		return True
	
	def skipProductionPopup(self,argsList):
		pCity = argsList[0]
		return False
		
	def showExamineCityButton(self,argsList):
		pCity = argsList[0]
		return True

	def getRecommendedUnit(self,argsList):
		pCity = argsList[0]
		return UnitTypes.NO_UNIT

	def getRecommendedBuilding(self,argsList):
		pCity = argsList[0]
		return BuildingTypes.NO_BUILDING

	def updateColoredPlots(self):
		return False

	def isActionRecommended(self,argsList):
		pUnit = argsList[0]
		iAction = argsList[1]
		return False

	def unitCannotMoveInto(self,argsList):
		ePlayer = argsList[0]		
		iUnitId = argsList[1]
		iPlotX = argsList[2]
		iPlotY = argsList[3]
		return False

	def cannotHandleAction(self,argsList):
		pPlot = argsList[0]
		iAction = argsList[1]
		bTestVisible = argsList[2]
		return False

	def canBuild(self,argsList):
		iX, iY, iBuild, iPlayer = argsList
		return -1	# Returning -1 means ignore; 0 means Build cannot be performed; 1 or greater means it can

	def cannotFoundCity(self,argsList):
		iPlayer, iPlotX, iPlotY = argsList
		pPlot = CyMap().plot(iPlotX,iPlotY)

		if pPlot.getBonusType(-1) == gc.getInfoTypeForString('BONUS_MANA'):
			return true

		return False

	def cannotSelectionListMove(self,argsList):
		pPlot = argsList[0]
		bAlt = argsList[1]
		bShift = argsList[2]
		bCtrl = argsList[3]
		return False

	def cannotSelectionListGameNetMessage(self,argsList):
		eMessage = argsList[0]
		iData2 = argsList[1]
		iData3 = argsList[2]
		iData4 = argsList[3]
		iFlags = argsList[4]
		bAlt = argsList[5]
		bShift = argsList[6]
		return False

	def cannotDoControl(self,argsList):
		eControl = argsList[0]
		return False

	def canResearch(self,argsList):
		ePlayer = argsList[0]
		eTech = argsList[1]
		bTrade = argsList[2]
		return False

	def cannotResearch(self,argsList):
		ePlayer = argsList[0]
		eTech = argsList[1]
		bTrade = argsList[2]
		pPlayer = gc.getPlayer(ePlayer)

		if eTech == gc.getInfoTypeForString('TECH_ORDERS_FROM_HEAVEN'):
			if gc.getGame().isOption(GameOptionTypes.GAMEOPTION_NO_RELIGION_1):
				return True
			if pPlayer.hasTrait(gc.getInfoTypeForString('TRAIT_AGNOSTIC')):
				return True
			if pPlayer.isHuman() == False:
				if pPlayer.getAlignment() != gc.getInfoTypeForString('ALIGNMENT_GOOD'):
					return True
		if eTech == gc.getInfoTypeForString('TECH_WAY_OF_THE_EARTHMOTHER'):
			if gc.getGame().isOption(GameOptionTypes.GAMEOPTION_NO_RELIGION_3):
				return True
			if pPlayer.hasTrait(gc.getInfoTypeForString('TRAIT_AGNOSTIC')):
				return True
			if pPlayer.isHuman() == False:
				if pPlayer.getAlignment() == gc.getInfoTypeForString('ALIGNMENT_EVIL'):
					return True
		if eTech == gc.getInfoTypeForString('TECH_WAY_OF_THE_FORESTS'):
			if gc.getGame().isOption(GameOptionTypes.GAMEOPTION_NO_RELIGION_0):
				return True
			if pPlayer.hasTrait(gc.getInfoTypeForString('TRAIT_AGNOSTIC')):
				return True
		if eTech == gc.getInfoTypeForString('TECH_MESSAGE_FROM_THE_DEEP'):
			if gc.getGame().isOption(GameOptionTypes.GAMEOPTION_NO_RELIGION_2):
				return True
			if pPlayer.hasTrait(gc.getInfoTypeForString('TRAIT_AGNOSTIC')):
				return True
			if pPlayer.isHuman() == False:
				if pPlayer.getAlignment() == gc.getInfoTypeForString('ALIGNMENT_GOOD'):
					return True
		if eTech == gc.getInfoTypeForString('TECH_CORRUPTION_OF_SPIRIT'):
			if gc.getGame().isOption(GameOptionTypes.GAMEOPTION_NO_RELIGION_4):
				return True
			if pPlayer.hasTrait(gc.getInfoTypeForString('TRAIT_AGNOSTIC')):
				return True
			if pPlayer.isHuman() == False:
				if pPlayer.getAlignment() != gc.getInfoTypeForString('ALIGNMENT_EVIL'):
					return True
		if eTech == gc.getInfoTypeForString('TECH_WAY_OF_THE_WISE'):
			if pPlayer.isHuman() == False:
				if pPlayer.getAlignment() == gc.getInfoTypeForString('ALIGNMENT_EVIL'):
					return True
		if eTech == gc.getInfoTypeForString('TECH_WAY_OF_THE_WICKED'):
			if pPlayer.isHuman() == False:
				if pPlayer.getAlignment() == gc.getInfoTypeForString('ALIGNMENT_GOOD'):
					return True
		if eTech == gc.getInfoTypeForString('TECH_HONOR'):
			if gc.getGame().isOption(GameOptionTypes.GAMEOPTION_NO_RELIGION_5):
				return True
			if pPlayer.hasTrait(gc.getInfoTypeForString('TRAIT_AGNOSTIC')):
				return True
			if pPlayer.isHuman() == False:
				if pPlayer.getAlignment() == gc.getInfoTypeForString('ALIGNMENT_EVIL'):
					return True
		if eTech == gc.getInfoTypeForString('TECH_DECEPTION'):
			if gc.getGame().isOption(GameOptionTypes.GAMEOPTION_NO_RELIGION_6):
				return True
			if pPlayer.hasTrait(gc.getInfoTypeForString('TRAIT_AGNOSTIC')):
				return True
			if pPlayer.isHuman() == False:
				if pPlayer.getAlignment() == gc.getInfoTypeForString('ALIGNMENT_GOOD'):
					return True

		if eTech == gc.getInfoTypeForString('TECH_SEAFARING'):
			if pPlayer.getCivilizationType() != gc.getInfoTypeForString('CIVILIZATION_LANUN'):
				return True

		return False

	def canDoCivic(self,argsList):
		ePlayer = argsList[0]
		eCivic = argsList[1]
		return False

	def cannotDoCivic(self,argsList):
		ePlayer = argsList[0]
		eCivic = argsList[1]
		return False
		
	def canTrain(self,argsList):
		pCity = argsList[0]
		eUnit = argsList[1]
		bContinue = argsList[2]
		bTestVisible = argsList[3]
		bIgnoreCost = argsList[4]
		bIgnoreUpgrades = argsList[5]
		return False

	def cannotTrain(self,argsList):
		pCity = argsList[0]
		eUnit = argsList[1]
		bContinue = argsList[2]
		bTestVisible = argsList[3]
		bIgnoreCost = argsList[4]
		bIgnoreUpgrades = argsList[5]
		ePlayer = pCity.getOwner()
		pPlayer = gc.getPlayer(ePlayer)
		eUnitClass = gc.getUnitInfo(eUnit).getUnitClassType()

		if pPlayer.isHuman() == False and bContinue == False:
			infoCiv = gc.getCivilizationInfo(pPlayer.getCivilizationType())
			if eUnitClass == gc.getInfoTypeForString('UNITCLASS_WARRIOR'):
				pPlot = pCity.plot()
				if pPlot.getNumUnits() >= 2:
					iTrainingYard = infoCiv.getCivilizationBuildings(gc.getInfoTypeForString('BUILDINGCLASS_TRAINING_YARD'))
					if iTrainingYard != -1:
						if pPlayer.canConstruct(iTrainingYard, False, False, False):
							return True
			if eUnitClass == gc.getInfoTypeForString('UNITCLASS_SCOUT'):
				iHuntingLodge = infoCiv.getCivilizationBuildings(gc.getInfoTypeForString('BUILDINGCLASS_HUNTING_LODGE'))
				if iHuntingLodge != -1:
					if pPlayer.canConstruct(iHuntingLodge, False, False, False):
						return True
			if eUnit == gc.getInfoTypeForString('UNIT_DEMAGOG'):
				if pPlayer.getUnitClassCount(gc.getInfoTypeForString('UNITCLASS_DEMAGOG')) > 6:
					return True
			if eUnitClass == gc.getInfoTypeForString('UNITCLASS_SETTLER'):
				if pPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_KHAZAD'):
					if pPlayer.getGold() / pPlayer.getNumCities() <= 149:
						return True
				if pPlayer.getUnitClassCountPlusMaking(gc.getInfoTypeForString('UNITCLASS_SETTLER')) > 1:
					return True
				if pCity.getPopulation() < 5:
					return True
			if eUnitClass == gc.getInfoTypeForString('UNITCLASS_WORKER'):
				if pPlayer.getCurrentEra() == gc.getInfoTypeForString('ERA_ANCIENT'):
					if pPlayer.getUnitClassCountPlusMaking(gc.getInfoTypeForString('UNITCLASS_WORKER')) > 1:
						return True
			if eUnitClass == gc.getInfoTypeForString('UNITCLASS_ADEPT'):
				if pPlayer.getUnitClassCount(gc.getInfoTypeForString('UNITCLASS_ADEPT')) > 2:
					return True
			if eUnitClass == gc.getInfoTypeForString('UNITCLASS_DISCIPLE_EMPYREAN'):
				if pPlayer.getUnitClassCount(gc.getInfoTypeForString('UNITCLASS_DISCIPLE_EMPYREAN')) > 2:
					return True
			if eUnitClass == gc.getInfoTypeForString('UNITCLASS_DISCIPLE_FELLOWSHIP_OF_LEAVES'):
				if pPlayer.getUnitClassCount(gc.getInfoTypeForString('UNITCLASS_DISCIPLE_FELLOWSHIP_OF_LEAVES')) > 2:
					return True
			if eUnitClass == gc.getInfoTypeForString('UNITCLASS_DISCIPLE_OCTOPUS_OVERLORDS'):
				if pPlayer.getUnitClassCount(gc.getInfoTypeForString('UNITCLASS_DISCIPLE_OCTOPUS_OVERLORDS')) > 2:
					return True
			if eUnitClass == gc.getInfoTypeForString('UNITCLASS_DISCIPLE_RUNES_OF_KILMORPH'):
				if pPlayer.getUnitClassCount(gc.getInfoTypeForString('UNITCLASS_DISCIPLE_RUNES_OF_KILMORPH')) > 2:
					return True
			if eUnitClass == gc.getInfoTypeForString('UNITCLASS_DISCIPLE_THE_ASHEN_VEIL'):
				if pPlayer.getUnitClassCount(gc.getInfoTypeForString('UNITCLASS_DISCIPLE_THE_ASHEN_VEIL')) > 2:
					return True
			if eUnitClass == gc.getInfoTypeForString('UNITCLASS_DISCIPLE_THE_ORDER'):
				if pPlayer.getUnitClassCount(gc.getInfoTypeForString('UNITCLASS_DISCIPLE_THE_ORDER')) > 2:
					return True

		if eUnit == gc.getInfoTypeForString('UNIT_BEAST_OF_AGARES'):
			if pCity.getPopulation() <= 5:
				return True

		if pPlayer.getCivics(gc.getInfoTypeForString('CIVICOPTION_CULTURAL_VALUES')) == gc.getInfoTypeForString('CIVIC_CRUSADE'):
			if eUnit == gc.getInfoTypeForString('UNIT_WORKER'):
				return True
			if eUnit == gc.getInfoTypeForString('UNIT_SETTLER'):
				return True
			if eUnit == gc.getInfoTypeForString('UNIT_WORKBOAT'):
				return True

		if eUnit == gc.getInfoTypeForString('UNIT_ACHERON'):
			if gc.getGame().isOption(GameOptionTypes.GAMEOPTION_NO_ACHERON):
					return True

		if eUnit == gc.getInfoTypeForString('UNIT_DUIN'):
			if gc.getGame().isOption(GameOptionTypes.GAMEOPTION_NO_DUIN):
					return True

		return False

	def canConstruct(self,argsList):
		pCity = argsList[0]
		eBuilding = argsList[1]
		bContinue = argsList[2]
		bTestVisible = argsList[3]
		bIgnoreCost = argsList[4]
		return False

	def cannotConstruct(self,argsList):
		pCity = argsList[0]
		eBuilding = argsList[1]
		bContinue = argsList[2]
		bTestVisible = argsList[3]
		bIgnoreCost = argsList[4]
		pPlayer = gc.getPlayer(pCity.getOwner())

		if pPlayer.getCivics(gc.getInfoTypeForString('CIVICOPTION_CULTURAL_VALUES')) == gc.getInfoTypeForString('CIVIC_CRUSADE'):
			if eBuilding == gc.getInfoTypeForString('BUILDING_ELDER_COUNCIL'):
				return True
			if eBuilding == gc.getInfoTypeForString('BUILDING_MARKET'):
				return True
			if eBuilding == gc.getInfoTypeForString('BUILDING_OBELISK'):
				return True
			if eBuilding == gc.getInfoTypeForString('BUILDING_MONEYCHANGER'):
				return True
			if eBuilding == gc.getInfoTypeForString('BUILDING_THEATRE'):
				return True
			if eBuilding == gc.getInfoTypeForString('BUILDING_AQUEDUCT'):
				return True
			if eBuilding == gc.getInfoTypeForString('BUILDING_PUBLIC_BATHS'):
				return True
			if eBuilding == gc.getInfoTypeForString('BUILDING_HERBALIST'):
				return True
			if eBuilding == gc.getInfoTypeForString('BUILDING_CARNIVAL'):
				return True
			if eBuilding == gc.getInfoTypeForString('BUILDING_COURTHOUSE'):
				return True
			if eBuilding == gc.getInfoTypeForString('BUILDING_GAMBLING_HOUSE'):
				return True
			if eBuilding == gc.getInfoTypeForString('BUILDING_GRANARY'):
				return True
			if eBuilding == gc.getInfoTypeForString('BUILDING_SMOKEHOUSE'):
				return True
			if eBuilding == gc.getInfoTypeForString('BUILDING_LIBRARY'):
				return True
			if eBuilding == gc.getInfoTypeForString('BUILDING_HARBOR'):
				return True
			if eBuilding == gc.getInfoTypeForString('BUILDING_ALCHEMY_LAB'):
				return True
			if eBuilding == gc.getInfoTypeForString('BUILDING_BREWERY'):
				return True

		if eBuilding == gc.getInfoTypeForString('BUILDING_SHRINE_OF_THE_CHAMPION'):
			iHero = cf.getHero(pPlayer)
			if iHero == -1:
				return True
			if CyGame().isUnitClassMaxedOut(iHero, 0) == False:
				return True
			if pPlayer.getUnitClassCount(iHero) > 0:
				return True

		if eBuilding == gc.getInfoTypeForString('BUILDING_MERCURIAN_GATE'):
			if gc.getGame().isOption(GameOptionTypes.GAMEOPTION_NO_HYBOREM_OR_BASIUM):
				return True
			if pPlayer.getStateReligion() == gc.getInfoTypeForString('RELIGION_THE_ASHEN_VEIL'):
				return True
			if pCity.isCapital():
				return True
			if pPlayer.isHuman() == False:
				if pPlayer.getAlignment() == gc.getInfoTypeForString('ALIGNMENT_EVIL'):
					return True

		iAltar1 = gc.getInfoTypeForString('BUILDING_ALTAR_OF_THE_LUONNOTAR')
		iAltar2 = gc.getInfoTypeForString('BUILDING_ALTAR_OF_THE_LUONNOTAR_ANOINTED')
		iAltar3 = gc.getInfoTypeForString('BUILDING_ALTAR_OF_THE_LUONNOTAR_BLESSED')
		iAltar4 = gc.getInfoTypeForString('BUILDING_ALTAR_OF_THE_LUONNOTAR_CONSECRATED')
		iAltar5 = gc.getInfoTypeForString('BUILDING_ALTAR_OF_THE_LUONNOTAR_DIVINE')
		iAltar6 = gc.getInfoTypeForString('BUILDING_ALTAR_OF_THE_LUONNOTAR_EXALTED')
		iAltar7 = gc.getInfoTypeForString('BUILDING_ALTAR_OF_THE_LUONNOTAR_FINAL')
		if (eBuilding == iAltar1 or eBuilding == iAltar2 or eBuilding == iAltar3 or eBuilding == iAltar4 or eBuilding == iAltar5 or eBuilding == iAltar6 or eBuilding == iAltar7):
			if pPlayer.getAlignment() == gc.getInfoTypeForString('ALIGNMENT_EVIL'):
				return True
			if eBuilding == iAltar1:
				if (pPlayer.countNumBuildings(iAltar2) > 0 or pPlayer.countNumBuildings(iAltar3) > 0 or pPlayer.countNumBuildings(iAltar4) > 0 or pPlayer.countNumBuildings(iAltar5) > 0 or pPlayer.countNumBuildings(iAltar6) > 0 or pPlayer.countNumBuildings(iAltar7) > 0):
					return True
			if eBuilding == iAltar2:
				if (pPlayer.countNumBuildings(iAltar3) > 0 or pPlayer.countNumBuildings(iAltar4) > 0 or pPlayer.countNumBuildings(iAltar5) > 0 or pPlayer.countNumBuildings(iAltar6) > 0 or pPlayer.countNumBuildings(iAltar7) > 0):
					return True
			if eBuilding == iAltar3:
				if (pPlayer.countNumBuildings(iAltar4) > 0 or pPlayer.countNumBuildings(iAltar5) > 0 or pPlayer.countNumBuildings(iAltar6) > 0 or pPlayer.countNumBuildings(iAltar7) > 0):
					return True
			if eBuilding == iAltar4:
				if (pPlayer.countNumBuildings(iAltar5) > 0 or pPlayer.countNumBuildings(iAltar6) > 0 or pPlayer.countNumBuildings(iAltar7) > 0):
					return True
			if eBuilding == iAltar5:
				if (pPlayer.countNumBuildings(iAltar6) > 0 or pPlayer.countNumBuildings(iAltar7) > 0):
					return True
			if eBuilding == iAltar6:
				if pPlayer.countNumBuildings(iAltar7) > 0:
					return True

		if pPlayer.isHuman() == False:
			if eBuilding == gc.getInfoTypeForString('BUILDING_PROPHECY_OF_RAGNAROK'):
				if pPlayer.getAlignment() != gc.getInfoTypeForString('ALIGNMENT_EVIL'):
					return True

		if eBuilding == gc.getInfoTypeForString('BUILDING_SMUGGLERS_PORT'):
			if pPlayer.isSmugglingRing() == False:
				return True

		return False

	def canCreate(self,argsList):
		pCity = argsList[0]
		eProject = argsList[1]
		bContinue = argsList[2]
		bTestVisible = argsList[3]
		return False

	def cannotCreate(self,argsList):
		pCity = argsList[0]
		eProject = argsList[1]
		bContinue = argsList[2]
		bTestVisible = argsList[3]
		pPlayer = gc.getPlayer(pCity.getOwner())

		if eProject == gc.getInfoTypeForString('PROJECT_ELEGY_OF_THE_SHEAIM'):
			if pPlayer.getCivilizationType() != gc.getInfoTypeForString('CIVILIZATION_SHEAIM'):
				return True
			if CyGame().getGlobalCounter() > 99:
				return True

		if eProject == gc.getInfoTypeForString('PROJECT_HALLOWING_OF_THE_ELOHIM'):
			if pPlayer.getCivilizationType() != gc.getInfoTypeForString('CIVILIZATION_ELOHIM'):
				return True
			if CyGame().getGlobalCounter() < 1:
				return True

		if eProject == gc.getInfoTypeForString('PROJECT_BANE_DIVINE'):
			if (CyGame().getGlobalCounter() < 70 and pCity.getProductionProject() != gc.getInfoTypeForString('PROJECT_BANE_DIVINE')):
				return True

		if eProject == gc.getInfoTypeForString('PROJECT_GLORY_EVERLASTING'):
			if (CyGame().getGlobalCounter() < 70 and pCity.getProductionProject() != gc.getInfoTypeForString('PROJECT_GLORY_EVERLASTING')):
				return True

		if eProject == gc.getInfoTypeForString('PROJECT_PURGE_THE_UNFAITHFUL'):
			if pPlayer.getStateReligion() == -1:
				return True

		if eProject == gc.getInfoTypeForString('PROJECT_BIRTHRIGHT_REGAINED'):
			if pPlayer.isFeatAccomplished(FeatTypes.FEAT_GLOBAL_SPELL) == False:
				return True

		return False

	def canMaintain(self,argsList):
		pCity = argsList[0]
		eProcess = argsList[1]
		bContinue = argsList[2]
		return False

	def cannotMaintain(self,argsList):
		pCity = argsList[0]
		eProcess = argsList[1]
		bContinue = argsList[2]
		return False

	def AI_chooseTech(self,argsList):
		ePlayer = argsList[0]
		bFree = argsList[1]
		pPlayer = gc.getPlayer(ePlayer)
		eTeam = gc.getTeam(pPlayer.getTeam())
		iTech = -1

		if pPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_BALSERAPHS'):
			iTech = gc.getInfoTypeForString('TECH_FESTIVALS')

		if pPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_BANNOR'):
			iTech = gc.getInfoTypeForString('TECH_BRONZE_WORKING')

		if pPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_CALABIM'):
			iTech = gc.getInfoTypeForString('TECH_FEUDALISM')

		if pPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_DOVIELLO'):
			iTech = gc.getInfoTypeForString('TECH_BRONZE_WORKING')

		if pPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_HIPPUS'):
			iTech = gc.getInfoTypeForString('TECH_HORSEBACK_RIDING')

		if pPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_KHAZAD'):
			iTech = gc.getInfoTypeForString('TECH_WAY_OF_THE_EARTHMOTHER')

		if pPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_LANUN'):
			iTech = gc.getInfoTypeForString('TECH_SAILING')

		if pPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_LJOSALFAR'):
			iTech = gc.getInfoTypeForString('TECH_WAY_OF_THE_FORESTS')

		if pPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_LUCHUIRP'):
			iTech = gc.getInfoTypeForString('TECH_CONSTRUCTION')

		if pPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_SVARTALFAR'):
			iTech = gc.getInfoTypeForString('TECH_HUNTING')

		if eTeam.isHasTech(gc.getInfoTypeForString('TECH_KNOWLEDGE_OF_THE_ETHER')):
			if (pPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_AMURITES') or pPlayer.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_SHEAIM')):
				iTech = gc.getInfoTypeForString('TECH_SORCERY')

		if eTeam.isHasTech(gc.getInfoTypeForString('TECH_EXPLORATION')) == False:
			iTech = gc.getInfoTypeForString('TECH_EXPLORATION')

		if eTeam.isHasTech(gc.getInfoTypeForString('TECH_PHILOSOPHY')):
			if pPlayer.getAlignment() == gc.getInfoTypeForString('ALIGNMENT_EVIL'):
				bAshValid = true
				bEsuValid = true
				for iTeam2 in range(gc.getMAX_PLAYERS()):
					eTeam2 = gc.getTeam(iTeam2)
					if eTeam2.isAlive():
						if eTeam2.isHasTech(gc.getInfoTypeForString('TECH_CORRUPTION_OF_SPIRIT')):
							bAshValid = false
						if eTeam2.isHasTech(gc.getInfoTypeForString('TECH_DECEPTION')):
							bEsuValid = false
				if bEsuValid == true:
					iTech = gc.getInfoTypeForString('TECH_DECEPTION')
				if bAshValid == true:
					iTech = gc.getInfoTypeForString('TECH_CORRUPTION_OF_SPIRIT')

		if eTeam.isHasTech(gc.getInfoTypeForString('TECH_PHILOSOPHY')):
			if pPlayer.getAlignment() == gc.getInfoTypeForString('ALIGNMENT_GOOD'):
				bOrdValid = true
				bEmpValid = true
				for iTeam2 in range(gc.getMAX_TEAMS()):
					eTeam2 = gc.getTeam(iTeam2)
					if eTeam2.isAlive():
						if eTeam2.isHasTech(gc.getInfoTypeForString('TECH_ORDERS_FROM_HEAVEN')):
							bOrdValid = false
						if eTeam2.isHasTech(gc.getInfoTypeForString('TECH_HONOR')):
							bEmpValid = false
				if bEmpValid == true:
					iTech = gc.getInfoTypeForString('TECH_HONOR')
				if bOrdValid == true:
					iTech = gc.getInfoTypeForString('TECH_ORDERS_FROM_HEAVEN')

		if pPlayer.getStateReligion() == gc.getInfoTypeForString('RELIGION_THE_ASHEN_VEIL'):
			bValid = true
			for iTeam2 in range(gc.getMAX_TEAMS()):
				eTeam2 = gc.getTeam(iTeam2)
				if eTeam2.isAlive():
					if eTeam2.isHasTech(gc.getInfoTypeForString('TECH_INFERNAL_PACT')):
						bValid = false
			if bValid == true:
				iTech = gc.getInfoTypeForString('TECH_INFERNAL_PACT')

		if iTech != -1:
			if eTeam.isHasTech(iTech) == False:
				return iTech

		return TechTypes.NO_TECH

	def AI_chooseProduction(self,argsList):
		pCity = argsList[0]
		return False

	def AI_unitUpdate(self,argsList):
		pUnit = argsList[0]

		if pUnit.getUnitClassType() == gc.getInfoTypeForString('UNITCLASS_GIANT_SPIDER'):
			iX = pUnit.getX()
			iY = pUnit.getY()
			for iiX in range(iX-1, iX+2, 1):
				for iiY in range(iY-1, iY+2, 1):
					pPlot = CyMap().plot(iiX,iiY)
					for i in range(pPlot.getNumUnits()):
						if pPlot.getUnit(i).getOwner() != pUnit.getOwner():
							return 0
			return 1

		if pUnit.getUnitClassType() == gc.getInfoTypeForString('UNITCLASS_HYBOREM'):
			if pUnit.isHasPromotion(gc.getInfoTypeForString('PROMOTION_IMMORTAL')) == False:
				pPlot = pUnit.plot()
				if pPlot.isCity():
					pCity = pPlot.getPlotCity()
					if pCity.getOwner() == pUnit.getOwner():
						return 1

		if pUnit.getOwner() == gc.getBARBARIAN_PLAYER():
			pPlot = pUnit.plot()
			if pPlot.getImprovementType() == gc.getInfoTypeForString('IMPROVEMENT_BARROW') or pPlot.getImprovementType() == gc.getInfoTypeForString('IMPROVEMENT_RUINS') or pPlot.getImprovementType() == gc.getInfoTypeForString('IMPROVEMENT_HELLFIRE') or pPlot.getImprovementType() == gc.getInfoTypeForString('IMPROVEMENT_BEAR_DEN') or pPlot.getImprovementType() == gc.getInfoTypeForString('IMPROVEMENT_LION_DEN'):
				if pPlot.getNumUnits() == 1:
					return 1

		if pUnit.getUnitClassType() == gc.getInfoTypeForString('UNITCLASS_BARBATOS'):
			return 1

		if pUnit.getUnitClassType() == gc.getInfoTypeForString('UNITCLASS_ACHERON'):
			return 1

		return False

	def AI_doWar(self,argsList):
		eTeam = argsList[0]
		return False

	def AI_doDiplo(self,argsList):
		ePlayer = argsList[0]
		return False

	def calculateScore(self,argsList):
		ePlayer = argsList[0]
		bFinal = argsList[1]
		bVictory = argsList[2]
		
		iPopulationScore = CvUtil.getScoreComponent(gc.getPlayer(ePlayer).getPopScore(), gc.getGame().getInitPopulation(), gc.getGame().getMaxPopulation(), gc.getDefineINT("SCORE_POPULATION_FACTOR"), True, bFinal, bVictory)
		iLandScore = CvUtil.getScoreComponent(gc.getPlayer(ePlayer).getLandScore(), gc.getGame().getInitLand(), gc.getGame().getMaxLand(), gc.getDefineINT("SCORE_LAND_FACTOR"), True, bFinal, bVictory)
		iTechScore = CvUtil.getScoreComponent(gc.getPlayer(ePlayer).getTechScore(), gc.getGame().getInitTech(), gc.getGame().getMaxTech(), gc.getDefineINT("SCORE_TECH_FACTOR"), True, bFinal, bVictory)
		iWondersScore = CvUtil.getScoreComponent(gc.getPlayer(ePlayer).getWondersScore(), gc.getGame().getInitWonders(), gc.getGame().getMaxWonders(), gc.getDefineINT("SCORE_WONDER_FACTOR"), False, bFinal, bVictory)
		return int(iPopulationScore + iLandScore + iWondersScore + iTechScore)

	def doHolyCity(self):
		return False

	def doHolyCityTech(self,argsList):
		eTeam = argsList[0]
		ePlayer = argsList[1]
		eTech = argsList[2]
		bFirst = argsList[3]
		return False

	def doGold(self,argsList):
		ePlayer = argsList[0]
		return False

	def doResearch(self,argsList):
		ePlayer = argsList[0]
		return False

	def doGoody(self,argsList):
		ePlayer = argsList[0]
		pPlot = argsList[1]
		pUnit = argsList[2]
		return False

	def doGrowth(self,argsList):
		pCity = argsList[0]
		return False

	def doProduction(self,argsList):
		pCity = argsList[0]
		return False

	def doCulture(self,argsList):
		pCity = argsList[0]
		return False

	def doPlotCulture(self,argsList):
		pCity = argsList[0]
		bUpdate = argsList[1]
		ePlayer = argsList[2]
		iCultureRate = argsList[3]
		return False

	def doReligion(self,argsList):
		pCity = argsList[0]
		return False

	def cannotSpreadReligion(self,argsList):
		iOwner, iUnitID, iReligion, iX, iY = argsList[0]
		return False

	def doGreatPeople(self,argsList):
		pCity = argsList[0]
		return False

	def doMeltdown(self,argsList):
		pCity = argsList[0]
		return False
	
	def doReviveActivePlayer(self,argsList):
		"allows you to perform an action after an AIAutoPlay"
		iPlayer = argsList[0]
		return False
	
	def doPillageGold(self, argsList):
		"controls the gold result of pillaging"
		pPlot = argsList[0]
		pUnit = argsList[1]
		
		iPillageGold = 0
		iPillageGold = CyGame().getSorenRandNum(gc.getImprovementInfo(pPlot.getImprovementType()).getPillageGold(), "Pillage Gold 1")
		iPillageGold += CyGame().getSorenRandNum(gc.getImprovementInfo(pPlot.getImprovementType()).getPillageGold(), "Pillage Gold 2")

		iPillageGold += (pUnit.getPillageChange() * iPillageGold) / 100
		
		return iPillageGold
	
	def doCityCaptureGold(self, argsList):
		"controls the gold result of capturing a city"
		
		pOldCity = argsList[0]
		
		iCaptureGold = 0
		
		iCaptureGold += gc.getDefineINT("BASE_CAPTURE_GOLD")
		iCaptureGold += (pOldCity.getPopulation() * gc.getDefineINT("CAPTURE_GOLD_PER_POPULATION"))
		iCaptureGold += CyGame().getSorenRandNum(gc.getDefineINT("CAPTURE_GOLD_RAND1"), "Capture Gold 1")
		iCaptureGold += CyGame().getSorenRandNum(gc.getDefineINT("CAPTURE_GOLD_RAND2"), "Capture Gold 2")

		if (gc.getDefineINT("CAPTURE_GOLD_MAX_TURNS") > 0):
			iCaptureGold *= cyIntRange((CyGame().getGameTurn() - pOldCity.getGameTurnAcquired()), 0, gc.getDefineINT("CAPTURE_GOLD_MAX_TURNS"))
			iCaptureGold /= gc.getDefineINT("CAPTURE_GOLD_MAX_TURNS")
		
		return iCaptureGold
	
	def citiesDestroyFeatures(self,argsList):
		iX, iY= argsList
		return True
		
	def canFoundCitiesOnWater(self,argsList):
		iX, iY= argsList
		return False
		
	def doCombat(self,argsList):
		pSelectionGroup, pDestPlot = argsList
		return False

	def getConscriptUnitType(self, argsList):
		iPlayer = argsList[0]
		iConscriptUnitType = -1 #return this with the value of the UNIT TYPE you want to be conscripted, -1 uses default system
		
		return iConscriptUnitType

	def getCityFoundValue(self, argsList):
		iPlayer, iPlotX, iPlotY = argsList
		iFoundValue = -1 # Any value besides -1 will be used
		
		return iFoundValue
		
	def canPickPlot(self, argsList):
		pPlot = argsList[0]
		return true
		
	def getUnitCostMod(self, argsList):
		iPlayer, iUnit = argsList
		iCostMod = -1 # Any value > 0 will be used
		
		return iCostMod

	def getBuildingCostMod(self, argsList):
		iPlayer, iCityID, iBuilding = argsList
		pPlayer = gc.getPlayer(iPlayer)
		pCity = pPlayer.getCity(iCityID)

		iCostMod = -1 # Any value > 0 will be used

		if iBuilding == gc.getInfoTypeForString('BUILDING_GAMBLING_HOUSE'):
			if pPlayer.isGamblingRing():
				iCostMod = gc.getBuildingInfo(iBuilding).getProductionCost() / 4
		
		return iCostMod
		
	def canUpgradeAnywhere(self, argsList):
		pUnit = argsList
		
		bCanUpgradeAnywhere = 0
		
		return bCanUpgradeAnywhere
		
	def getWidgetHelp(self, argsList):
		eWidgetType, iData1, iData2, bOption = argsList
		
		return u""
		
	def getUpgradePriceOverride(self, argsList):
		iPlayer, iUnitID, iUnitTypeUpgrade = argsList
		
		return -1	# Any value 0 or above will be used
	
	def getExperienceNeeded(self, argsList):
		# use this function to set how much experience a unit needs
		iLevel, iOwner = argsList
		
		iExperienceNeeded = 0

		# regular epic game experience		
		iExperienceNeeded = iLevel * iLevel + 1

		iModifier = gc.getPlayer(iOwner).getLevelExperienceModifier()
		if (0 != iModifier):
			iExperienceNeeded += (iExperienceNeeded * iModifier + 99) / 100   # ROUND UP
			
		return iExperienceNeeded
